// pages/check/store/store.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		http: getApp().globalData.map
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		wx.request({
			url: getApp().globalData.http1 + 'action=getShopInfo&uid=' + 97,
			success: (e) => {
				console.log(e)
				this.setData({
					data: e.data.data
				})
			}
		})
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				this.setData({
					uid: e.data.uid
				})
				wx.request({
					url: getApp().globalData.http1 + 'action=getShopInfo&uid=' + e.data.uid,
					success: (e) => {
						console.log(e)
						this.setData({
							data: e.data.data,
							img: e.data.data.ShopImage
						})
					}
				})
			}
		})
	},
	img() {
		let that=this
		wx.chooseImage({
			count: 1,
			sizeType: 'compressed',
			success: (e) => {
				console.log(e)
				let a = this.data.data
				wx.uploadFile({
					url: getApp().globalData.http3,
					filePath: e.tempFilePaths[0],
					name: 'picturePath',
					success: function(res) {
						let c = JSON.parse(res.data)
						let img=c.data.headImage
						a.ShopImage=getApp().globalData.map+c.data.headImage
						console.log(a)
						that.setData({
							img:img,
							data: a,
							http: ''
						})
					},
				})
				
			}
		})
	},
	name(e) {
		let a = this.data.data
		a.RealName = e.detail.value
		this.setData({
			data: a
		})
	},
	mobile(e) {
		let a = this.data.data
		a.Mobile = e.detail.value
		this.setData({
			data: a
		})
	},
	brief(e) {
		let a = this.data.data
		a.Remark = e.detail.value
		this.setData({
			data: a
		})
	},
	sure() {
		let that = this
		let a = this.data.data
		wx.request({
			url: getApp().globalData.http1 + 'action=updateShopInfo&uid=' + that.data.uid + '&mobile=' + a.Mobile +
				'&shopInfo=' +
				a.Remark + '&realName=' + a.RealName + '&shopImg=' + this.data.img,
			success: (e) => {
				console.log(e)
				wx.navigateBack({
					delta: 1
				})
			}
		})
	}
})
